const fetch = (...args) =>
  import('node-fetch').then(({ default: fetch }) => fetch(...args))

async function testAPI () {
  try {
    console.log('测试基础小说列表接口...')
    const novelsResponse = await fetch('http://localhost:3000/api/novels')
    const novelsData = await novelsResponse.json()
    console.log('小说列表响应:', novelsData)

    console.log('\n测试热门小说接口...')
    const popularResponse = await fetch(
      'http://localhost:3000/api/novels?sort=popular&limit=5'
    )
    const popularData = await popularResponse.json()
    console.log('热门小说响应:', popularData)

    console.log('\n测试推荐接口...')
    const recommendResponse = await fetch(
      'http://localhost:3000/api/novels/recommendations'
    )
    const recommendData = await recommendResponse.json()
    console.log('推荐接口响应:', recommendData)
  } catch (error) {
    console.error('测试失败:', error)
  }
}

testAPI()
